package com.wyix;

import com.wyix.entity.Car;
import com.wyix.entity.ElectricCar;
import com.wyix.entity.SalesRecord;

/**
 * @author wangdx
 * @since 2025/8/1
 */
public class CarSalesSystem {
    public static void main(String[] args) {
        // 创建不同类型的汽车对象
        Car bmw = new Car("宝马", "5系", 459900, "蓝色", 2023);
        ElectricCar tesla = new ElectricCar("特斯拉", "Model 3", 231900,
                "银色", 2023, 60.0, 556);

        // 多态体现：父类引用指向子类对象
        Car audi = new ElectricCar("奥迪", "Q4 e-tron", 356000,
                "灰色", 2023, 77.0, 605);

        // 电动车特有操作
        if (tesla instanceof ElectricCar) {
            ElectricCar teslaEV = (ElectricCar) tesla;
            teslaEV.charge();
            double costPerKm = teslaEV.calculateCostPerKm(0.56); // 电价0.56元/度
            System.out.println(tesla.getBrand() + tesla.getModel() + "每公里成本: " + costPerKm + "元");
        }

        // 创建销售记录
        SalesRecord sale1 = new SalesRecord(bmw, 449900, "张三");
        SalesRecord sale2 = new SalesRecord(tesla, 229900, "李四");
        SalesRecord sale3 = new SalesRecord(audi, 346000, "王五");

        // 打印销售单
        sale1.printSalesReceipt();
        sale2.printSalesReceipt();

        // 统计总销售数量
        System.out.println("\n当前总销售记录数: " + SalesRecord.getTotalSalesCount());
    }
}
